# Definition for singly-linked list.
class ListNode:
    def __init__(self, x):
        self.val = x
        self.next = None

class Solution:
    def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
        a1 = []
        a2 = []
        t1 = l1
        t2 = l2
        while t1 != None:
            a1.append(t1.val)
            t1 = t1.next
        while t2 != None:
            a2.append(t2.val)
            t2 = t2.next
        s1 = 0
        s2 = 0
        while len(a1) > 0:
            t = a1.pop()
            for _ in a1:
                t = t * 10
            s1 = s1 + t
        while len(a2) > 0:
            t = a2.pop()
            for _ in a2:
                t = t * 10
            s2 = s2 + t
        s3 = list(str(s1 + s2))
        head = ListNode(int(s3.pop()))
        h = head
        while len(s3) > 0:
            h.next = ListNode(int(s3.pop()))
            h = h.next
        return head